Return 404 for requests to paths the Flask mock does not serve - #3384
Open
adamtheturtle wants to merge 3 commits into
Open
Return 404 for requests to paths the Flask mock does not serve#3384adamtheturtle wants to merge 3 commits into
adamtheturtle wants to merge 3 commits into
Conversation
The Flask app's ``validate_request`` before_request hook ran for requests which match no route, because Flask runs before_request handlers before it raises the routing error. ``validate_keys`` then unpacked an empty generator and raised a ``ValueError``, so any authenticated request to an unknown path, or to a known path with a method it does not serve, crashed the Flask and Docker backends. Skip validation when Flask has matched no route, so Flask raises its own routing error: 404 for an unknown path, as real Vuforia returns, and 405 for an unserved method. Closes #3368 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
adamtheturtle
temporarily deployed
to
development
August 9, 2026 17:22 — with
GitHub Actions
Inactive
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Real Vuforia returns a 404 response both for a request to a path which it does not serve and for a request to a served path with a method which that path does not serve; it does not return a 405. Make the Flask app return a 404 with no body in both cases, rather than Flask's 404 page or a 405. Add verified fake tests which run against real Vuforia and the mocks, and record in the differences documentation which bodies real Vuforia gives. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
validate_requestis abefore_requesthook, and Flask runs those before it raises a routing error, so requests matching no route reachedvalidate_keys, which unpacked an empty generator and raisedValueError— crashing the Flask and Docker backends for any authenticated request to an unknown path or to a known path with an unserved method.This skips validation when Flask has matched no route (
request.url_rule is None), leaving Flask to raise its own routing error: 404 for an unknown path, as real Vuforia returns, and 405 for an unserved method.Tests use the Flask test client, since
responsesintercepts only the paths the app routes; a further test covers the unauthenticated probe the Docker health check makes, which now sees 404 instead of 401 (both are in its accepted set). The new behaviour and the unverified response bodies are documented in the differences doc.Closes #3368
🤖 Generated with Claude Code